#include "Topography.h"
#include "config.h"
#include <cmath>

Topography::Topography(CCNode * parent, b2World * w, const CCPoint & sp)
: GameEntity(w)
, pParent(parent)
, startPoint(sp)
{
}

EntityType Topography::getEntityType()
{
  return GROUND;
}

Topography::~Topography()
{
}

void Topography::contactBeganWithPlayer(Player * pPlayer, b2Contact * pContact)
{
  pPlayer->setCanJump();
}

void Topography::contactEndWithPlayer(Player * pPlayer, b2Contact * pContact)
{
}

void Topography::destroyBody()
{
  if (pParent)
  {
    for (int i = 0; i < this->childBody.size(); i++)
    {
      pParent->removeChild(this->childBody.at(i));
    }
  }
}

CCPoint Topography::getEndPoint()
{
  return this->endPoint;
}

void Topography::addEntity(GameEntity * pChild)
{
  if (pChild)
  {
    this->childBody.push_back(pChild);
    pParent->addChild(pChild);
  }
}
